package com.mck.controller;

import com.mck.entity.Result;
import com.mck.entity.Title;
import com.mck.service.TitleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/public/title")
@Slf4j
public class TitleController {

    @Autowired
    private TitleService titleService;

    /**
     * 获取系统标题
     */
    @GetMapping
    public Result getTitle() {
        log.info("获取系统标题");

        Title title = titleService.getTitle();
        return Result.success(title);
    }

    /**
     * 更新系统标题
     */
    @PutMapping
    public Result updateTitle( @RequestBody Title title) {   // @RequestBody 将请求体中的json数据转换为Title对象
        System.out.println(title);
        log.info("修改系统标题");

        titleService.updateTitle(title);
        return Result.success();
    }
}
